package com.sunwayhorizo.health.hl7.persistent;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.TableGenerator;

import com.sunwayhorizo.health.hl7.datatypes.common.CSImpl;

/**
 * 
 * =============================================================
 * 
 * @ClassName RimCoreEds <br>
 * @PackageName com.sunwayhorizo.health.hl7.persistent <br>
 * @Description 动作描述，ED类型数据 增加ED_BLOB，对二进制数据的支持 <br>
 * @Author jinzw <br>
 * @Date 2010-11-9 <br>
 * @Version 1.0 <br>
 * @ModifiedDesc <br>
 * @ModifiedDate <br>
 * @ModifiedBy <br>
 * @Email tanll@sunwaysoft.com.cn <br>
 * @Copyright 2010-2020 北京三维海容 All Rights Reserved. <br>
 *            =============================================================
 */
@Entity
//@TableGenerator(name = "Ed_IdGenerator", table = "RIM_Id_Generator", pkColumnName = "pkColumn", valueColumnName = "valueColumn", pkColumnValue = "Ed_Id")
@NamedQuery(name = "RimCoreEds.findRimCoreEdsByEdId", query = "select o from RimCoreEds o where o.edId=?1")
@Table(name = "RIM_CORE_EDS")
public class RimCoreEds implements Serializable
{
    @Id
//    @GeneratedValue(strategy = GenerationType.TABLE, generator = "Ed_IdGenerator")
    @Column(name = "ED_ID", nullable = false)
    private Long edId;

    @Column(name = "MEDIA_TYPE_CODE")
    private String mediaTypeCode;
    @Column(name = "CHARACTER_SET_CODE")
    private String characterSetCode;
    @Column(name = "LANGUAGE_CODE")
    private String languageCode;
    @Column(name = "COMPRESSION_CODE")
    private String compressionCode;
    @Column(name = "REF_TEL_ADDRESS_TXT")
    private String refTelAddressTxt;
    @Column(name = "REF_TEL_SCHEME_CODE")
    private String refTelSchemeCode;
    @Column(name = "REF_TEL_START_DATE_TS")
    private Timestamp refTelStartDateTs;
    @Column(name = "REF_TEL_END_DATE_TS")
    private Timestamp refTelEndDateTs;
    @Column(name = "REF_TEL_GTS_TXT")
    private String refTelGtsTxt;
    @Column(name = "INTEGRITY_CHECK_ALG_CODE")
    private String integrityCheckAlgCode;
    @Column(name = "INTEGRITY_CHECK_TXT")
    private String integrityCheckTxt;
    @Column(name = "ED_CLOB")
    private char[] edClob; // 文本型
    @Column(name = "ED_BLOB")
    private byte[] edBlob; // 二进制型
    @Column(name = "ENCODING_TYPE_CODE")
    private String encodingTypeCode;

    @Column(name = "CREATED_BY", nullable = false)
    private Long createdBy;
    @Column(name = "CREATION_DATE", nullable = false)
    private Timestamp creationDate;
    @Column(name = "LAST_UPDATED_BY", nullable = false)
    private Long lastUpdatedBy;
    @Column(name = "LAST_UPDATE_DATE", nullable = false)
    private Timestamp lastUpdateDate;
    @Column(name = "LAST_UPDATE_LOGIN")
    private Long lastUpdateLogin;

    @OneToMany(mappedBy = "rimCoreEds", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    private List<RimCoreEdRefTelUses> rimCoreEdRefTelUsesList = new ArrayList();
    @OneToMany(mappedBy = "rimCoreEdsThumbnailEdId", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    private List<RimCoreEds> rimCoreEdsThumbnailEdIdList = new ArrayList();
    /*
     * //Entity.desc ED
     * 
     * @OneToMany(mappedBy = "rimCoreEdsDescEdId",cascade = CascadeType.ALL,
     * fetch = FetchType.LAZY) private List<RimCoreEntities>
     * rimCoreEdsDescEdIdList = new ArrayList();
     * 
     * //NonPersonLivingSubject.strainText ED
     * 
     * @OneToMany(mappedBy = "rimCoreEdsNpStrainTextId",cascade =
     * CascadeType.ALL, fetch = FetchType.LAZY) private List<RimCoreEntities>
     * rimCoreEdsNpStrainTextIdList = new ArrayList();
     * 
     * //Place.directionsText ED
     * 
     * @OneToMany(mappedBy = "rimCoreEdsPlDirectionsTextId",cascade =
     * CascadeType.ALL, fetch = FetchType.LAZY) private List<RimCoreEntities>
     * rimCoreEdsPlDirectionsTextIdList = new ArrayList();
     * 
     * //Place.positionText ED
     * 
     * @OneToMany(mappedBy = "rimCoreEdsPlPositionTextId",cascade =
     * CascadeType.ALL, fetch = FetchType.LAZY) private List<RimCoreEntities>
     * rimCoreEdsPlPositionTextIdList = new ArrayList();
     * 
     * //Role.certificateText ED
     * 
     * @OneToMany(mappedBy = "rimCoreEdsCertificateTxtEdId",cascade =
     * CascadeType.ALL, fetch = FetchType.LAZY) private List<RimCoreRoles>
     * rimCoreEdsCertificateTxtEdIdList = new ArrayList();
     * 
     * //Employee.hazardExposureText ED
     * 
     * @OneToMany(mappedBy = "rimCoreEdsEmHazardExposureEdId",cascade =
     * CascadeType.ALL, fetch = FetchType.LAZY) private List<RimCoreRoles>
     * rimCoreEdsEmHazardExposureEdIdList = new ArrayList();
     * 
     * //Employee.protectiveEquipmentText ED
     * 
     * @OneToMany(mappedBy = "rimCoreEdsEmProtectiveEqpEdId",cascade =
     * CascadeType.ALL, fetch = FetchType.LAZY) private List<RimCoreRoles>
     * rimCoreEdsEmProtectiveEqpEdIdList = new ArrayList();
     * 
     * //Participation.noteText ED
     * 
     * @OneToMany(mappedBy = "rimCoreEdsNoteTextEdId",cascade = CascadeType.ALL,
     * fetch = FetchType.LAZY) private List<RimCoreActPrtcptns>
     * rimCoreEdsNoteTextEdIdList = new ArrayList();
     * 
     * //Participation.signatureText ED
     * 
     * @OneToMany(mappedBy = "rimCoreEdsSignatureTextEdId",cascade =
     * CascadeType.ALL, fetch = FetchType.LAZY) private List<RimCoreActPrtcptns>
     * rimCoreEdsSignatureTextEdIdList = new ArrayList();
     * 
     * //Act.text ED
     * 
     * @OneToMany(mappedBy = "rimCoreEdsTextEdId",cascade = CascadeType.ALL,
     * fetch = FetchType.LAZY) private List<RimCoreActs> rimCoreActTextEdIdList
     * = new ArrayList();
     * 
     * //Observation.value ED,不需要了。
     * 
     * @OneToMany(mappedBy = "rimCoreEdsObValueEdId",cascade = CascadeType.ALL,
     * fetch = FetchType.LAZY) private List<RimCoreActs>
     * rimCoreActObValueEdIdList = new ArrayList();
     */
    @ManyToOne
    @JoinColumn(name = "THUMBNAIL_ED_ID")
    private RimCoreEds rimCoreEdsThumbnailEdId;


    public RimCoreEds()
    {
        Long i = new Long(1);
        Timestamp nowTime = new Timestamp(new Date().getTime());

        createdBy = i;
        creationDate = nowTime;
        lastUpdatedBy = i;
        lastUpdateDate = nowTime;
        lastUpdateLogin = i;
    }


    public String getCharacterSetCode()
    {
        return characterSetCode;
    }


    public void setCharacterSetCode(String characterSetCode)
    {
        this.characterSetCode = characterSetCode;
    }


    public String getCompressionCode()
    {
        return compressionCode;
    }


    public void setCompressionCode(String compressionCode)
    {
        this.compressionCode = compressionCode;
    }


    public Long getCreatedBy()
    {
        return createdBy;
    }


    public void setCreatedBy(Long createdBy)
    {
        this.createdBy = createdBy;
    }


    public Timestamp getCreationDate()
    {
        return creationDate;
    }


    public void setCreationDate(Timestamp creationDate)
    {
        this.creationDate = creationDate;
    }


    public char[] getEdClob()
    {
        return edClob;
    }


    public void setEdClob(char[] edClob)
    {
        this.edClob = edClob;
    }


    /**
     * @return the edBlob
     */
    public byte[] getEdBlob()
    {
        return edBlob;
    }


    /**
     * @param edBlob
     *            the edBlob to set
     */
    public void setEdBlob(byte[] edBlob)
    {
        this.edBlob = edBlob;
    }


    public Long getEdId()
    {
        return edId;
    }


    public void setEdId(Long edId)
    {
        this.edId = edId;
    }


    public String getEncodingTypeCode()
    {
        return encodingTypeCode;
    }


    public void setEncodingTypeCode(String encodingTypeCode)
    {
        this.encodingTypeCode = encodingTypeCode;
    }


    public String getIntegrityCheckAlgCode()
    {
        return integrityCheckAlgCode;
    }


    public void setIntegrityCheckAlgCode(String integrityCheckAlgCode)
    {
        this.integrityCheckAlgCode = integrityCheckAlgCode;
    }


    public String getIntegrityCheckTxt()
    {
        return integrityCheckTxt;
    }


    public void setIntegrityCheckTxt(String integrityCheckTxt)
    {
        this.integrityCheckTxt = integrityCheckTxt;
    }


    public String getLanguageCode()
    {
        return languageCode;
    }


    public void setLanguageCode(String languageCode)
    {
        this.languageCode = languageCode;
    }


    public Long getLastUpdatedBy()
    {
        return lastUpdatedBy;
    }


    public void setLastUpdatedBy(Long lastUpdatedBy)
    {
        this.lastUpdatedBy = lastUpdatedBy;
    }


    public Timestamp getLastUpdateDate()
    {
        return lastUpdateDate;
    }


    public void setLastUpdateDate(Timestamp lastUpdateDate)
    {
        this.lastUpdateDate = lastUpdateDate;
    }


    public Long getLastUpdateLogin()
    {
        return lastUpdateLogin;
    }


    public void setLastUpdateLogin(Long lastUpdateLogin)
    {
        this.lastUpdateLogin = lastUpdateLogin;
    }


    public String getMediaTypeCode()
    {
        return mediaTypeCode;
    }


    public void setMediaTypeCode(String mediaTypeCode)
    {
        this.mediaTypeCode = mediaTypeCode;
    }


    public String getRefTelAddressTxt()
    {
        return refTelAddressTxt;
    }


    public void setRefTelAddressTxt(String refTelAddressTxt)
    {
        this.refTelAddressTxt = refTelAddressTxt;
    }


    public Timestamp getRefTelEndDateTs()
    {
        return refTelEndDateTs;
    }


    public void setRefTelEndDateTs(Timestamp refTelEndDateTs)
    {
        this.refTelEndDateTs = refTelEndDateTs;
    }


    public String getRefTelGtsTxt()
    {
        return refTelGtsTxt;
    }


    public void setRefTelGtsTxt(String refTelGtsTxt)
    {
        this.refTelGtsTxt = refTelGtsTxt;
    }


    public String getRefTelSchemeCode()
    {
        return refTelSchemeCode;
    }


    public void setRefTelSchemeCode(String refTelSchemeCode)
    {
        this.refTelSchemeCode = refTelSchemeCode;
    }


    public Timestamp getRefTelStartDateTs()
    {
        return refTelStartDateTs;
    }


    public void setRefTelStartDateTs(Timestamp refTelStartDateTs)
    {
        this.refTelStartDateTs = refTelStartDateTs;
    }


    public RimCoreEds getRimCoreEds()
    {
        return rimCoreEdsThumbnailEdId;
    }


    public void setRimCoreEds(RimCoreEds rimCoreEdsThumbnailEdId)
    {
        this.rimCoreEdsThumbnailEdId = rimCoreEdsThumbnailEdId;
    }


    private List<RimCoreEdRefTelUses> getRimCoreEdRefTelUsesList()
    {
        return rimCoreEdRefTelUsesList;
    }


    private void setRimCoreEdRefTelUsesList(List<RimCoreEdRefTelUses> rimCoreEdRefTelUsesList)
    {
        this.rimCoreEdRefTelUsesList = rimCoreEdRefTelUsesList;
    }


    private RimCoreEdRefTelUses addRimCoreEdRefTelUses(RimCoreEdRefTelUses rimCoreEdRefTelUses)
    {
        this.getRimCoreEdRefTelUsesList().add(rimCoreEdRefTelUses);
        rimCoreEdRefTelUses.setRimCoreEds(this);
        return rimCoreEdRefTelUses;
    }


    private RimCoreEdRefTelUses removeRimCoreEdRefTelUses(RimCoreEdRefTelUses rimCoreEdRefTelUses)
    {
        this.getRimCoreEdRefTelUsesList().remove(rimCoreEdRefTelUses);
        rimCoreEdRefTelUses.setRimCoreEds(null);
        return rimCoreEdRefTelUses;
    }


    public void setEdRefTelUses(Set mSet)
    {
        if (!mSet.isEmpty())
        {
            CSImpl use = (CSImpl) mSet.iterator().next();
            RimCoreEdRefTelUses edRefTelUses = new RimCoreEdRefTelUses();
            edRefTelUses.setUse(use.code().toString());
            this.addRimCoreEdRefTelUses(edRefTelUses);
        }
    }


    private List<RimCoreEds> getRimCoreEdsThumbnailEdIdList()
    {
        return rimCoreEdsThumbnailEdIdList;
    }


    private void setRimCoreEdsThumbnailEdIdList(List<RimCoreEds> rimCoreEdsThumbnailEdIdList)
    {
        this.rimCoreEdsThumbnailEdIdList = rimCoreEdsThumbnailEdIdList;
    }


    public RimCoreEds addRimCoreEds(RimCoreEds rimCoreEds)
    {
        getRimCoreEdsThumbnailEdIdList().add(rimCoreEds);
        rimCoreEds.setRimCoreEds(this);
        return rimCoreEds;
    }


    public RimCoreEds removeRimCoreEds(RimCoreEds rimCoreEds)
    {
        getRimCoreEdsThumbnailEdIdList().remove(rimCoreEds);
        rimCoreEds.setRimCoreEds(null);
        return rimCoreEds;
    }
    //

}
